@extends('layouts.admin')
@section('content')
<table class="table table-hover">
    <tr class="active">
        <th width="30">id</th>
        <th>汽车名</th>
        <th>价钱</th>
        <th>车牌号</th>
        <th width="200">操作</th>
    </tr>
    @foreach($data as $v)
    <tr>
        <td>{{$v->id}}</td>
        <td>{{$v->carname}}</td>
        <td>{{$v->cprice}}</td>
        <td>{{$v->carID}}</td>
        <td>
            <a href="{{url('admin/car/'.$v->id.'/edit')}}" class="btn btn-sm btn-warning">编辑</a>
            <a href="javascript:;" class="btn btn-sm btn-danger" onclick="delCar({{$v->id}})">删除</a>
        </td>
    </tr>
        @endforeach
</table>
<script>
    //删除分类
    function delCar(id) {
        layer.confirm('您确定要删除这篇文章吗？', {
            btn: ['确定','取消'] //按钮
        }, function(){
            $.post("{{url('admin/car/')}}/"+id,{'_method':'delete','_token':"{{csrf_token()}}"},function (data) {
                if(data.status==0){
                    location.href = location.href;
                    layer.msg(data.msg, {icon: 6});
                }else{
                    layer.msg(data.msg, {icon: 5});
                }
            });
//            layer.msg('的确很重要', {icon: 1});
        }, function(){

        });
    }
</script>
@endsection
